﻿Public Class br
    'Обявление переменных
    Dim setting1 As New My.MySettings
    Dim webitem As String
    Dim box As Integer
    Dim homepage As String = "http://ytdb.ru/showthread.php?p=13098#post13098"
    Dim urlwowhead As String
    Dim urlarmory As String
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Кнопка для перехода по адрессу TextBox1.Text
        WebBrowser1.Navigate(TextBox1.Text)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        'Закрытие br
        Me.Close()
    End Sub

    Private Sub br_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'load
        If Form1.brs = 1 Then
            webitem = setting1.webitem
            box = Form1.TextBox1.Text
            urlwowhead = "http://ru.wowhead.com/item="
            urlarmory = "http://eu.battle.net/wow/ru/item/"
            Button8.Enabled = True
        End If
        If Form1.brs = 2 Then
            webitem = setting1.webnpc
            box = Form1.TextBox7.Text
            urlwowhead = "http://ru.wowhead.com/npc="
            Button8.Enabled = False
        End If
        If Form1.brs = 3 Then
            webitem = setting1.webobj
            box = Form1.TextBox17.Text
            urlwowhead = "http://ru.wowhead.com/object="
            Button8.Enabled = False
        End If
        If Form1.brs = 4 Then
            webitem = setting1.webqve
            box = Form1.TextBox10.Text
            urlwowhead = "http://ru.wowhead.com/quest="
            Button8.Enabled = False
        End If
        'Загрузка итема соответственно с указаеым в form1
        Panel1.Height = 42
        WebBrowser1.Navigate(webitem & box)
        TextBox1.Text = webitem & box
        ToolStripStatusLabel1.Text = String.Format(My.Application.Info.AssemblyName & " " & My.Application.Info.Version.ToString)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        'Код возвращения браузера на предыдущую страницу
        WebBrowser1.GoBack()
    End Sub
    Private Sub WebBrowser1_ProgressChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowser1.ProgressChanged
        'ToolStripProgressBar
        ToolStripProgressBar1.Maximum = e.MaximumProgress
        ToolStripProgressBar1.Value = e.CurrentProgress
        If e.CurrentProgress = 0 Then
            ToolStripProgressBar1.Visible = False
        Else
            ToolStripProgressBar1.Visible = True
        End If
    End Sub

    Private Sub ToolStripStatusLabel2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripStatusLabel2.Click
        'Ссылка homepage
        TextBox1.Text = homepage
        WebBrowser1.Navigate(TextBox1.Text)
    End Sub
    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        'Механизм "+1"
        box = box + 1
        WebBrowser1.Navigate(webitem & box)
        TextBox1.Text = webitem & box
        If Form1.brs = 1 Then
            Form1.TextBox1.Text = box
        End If
        If Form1.brs = 2 Then
            Form1.TextBox7.Text = box
        End If
        If Form1.brs = 3 Then
            Form1.TextBox17.Text = box
        End If
        If Form1.brs = 4 Then
            Form1.TextBox10.Text = box
        End If
    End Sub
    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        'Открытие настроек
        If Panel1.Height = 42 Then
            Panel1.Height = 82
        Else
            Panel1.Height = 42
        End If
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        'Загрузка с wowhead
        webitem = urlwowhead
        WebBrowser1.Navigate(webitem & box)
        TextBox1.Text = webitem & box
        If Form1.brs = 1 Then
            setting1.webitem = webitem
            setting1.Save()
        End If
    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        'Загрузка с eu.wowarmory.com
        webitem = urlarmory
        WebBrowser1.Navigate(webitem & box)
        TextBox1.Text = webitem & box
        If Form1.brs = 1 Then
            setting1.webitem = webitem
            setting1.Save()
        End If
    End Sub

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        'Автозаполнение
        WebBrowser1.Navigate(webitem & box)
        If Form1.brs = 1 Then
            Form1.TextBox2.Text = WebBrowser1.DocumentTitle
            Form1.TextBox2.Text = Form1.TextBox2.Text.Replace(" - Предмет - World of Warcraft", "")
        End If
        If Form1.brs = 2 Then
            Form1.TextBox6.Text = WebBrowser1.DocumentTitle
            Form1.TextBox6.Text = Form1.TextBox6.Text.Replace(" - НИП - World of Warcraft", "")
        End If
        If Form1.brs = 3 Then
            Form1.TextBox16.Text = WebBrowser1.DocumentTitle
            Form1.TextBox16.Text = Form1.TextBox16.Text.Replace(" - Объект - World of Warcraft", "")
        End If
        If Form1.brs = 4 Then
            Form1.TextBox9.Text = WebBrowser1.DocumentTitle
            Form1.TextBox9.Text = Form1.TextBox9.Text.Replace(" - Задание - World of Warcraft", "")
        End If
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
    'Переход браузера на следующую страницу
        WebBrowser1.GoForward()
    End Sub

    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        'Заголовок
        Me.Text = "Web Browser Item - " & WebBrowser1.DocumentTitle
    End Sub
End Class